package cn.hiapi.admin.api;

import cn.hiapi.admin.query.ActivityCategoryQuery;
import cn.hiapi.admin.vo.ActivityCategoryVo;
import cn.hiapi.basic.controller.BasicCurdController;
import cn.hiapi.basic.service.BasicService;
import cn.hiapi.interfaces.DispatchContext;
import cn.hiapi.shopkeeper.entity.activity.ActivityCategory;
import cn.hiapi.shopkeeper.service.activity.ActivityCategoryService;
import cn.hiapi.system.entity.article.ArticleCategory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author AdinZ
 * @date 2022/12/16 22:01
 */
@RestController
@RequestMapping("/manage/activity-category")
public class ActivityCategoryController extends BasicCurdController<ActivityCategory, Long, ActivityCategoryVo, ActivityCategoryQuery> {
    public ActivityCategoryController(ActivityCategoryService basicService, DispatchContext dispatchContext) {
        super(basicService, dispatchContext);
    }

    @Override
    public ActivityCategory parseData(ActivityCategoryVo data) {
        return data.copy(new ActivityCategory());
    }

    @Override
    public List<ActivityCategoryVo> toListVo(List<ActivityCategory> list, String[] fields) {
        return list.stream().map(e -> this.toData(e, fields)).collect(Collectors.toList());
    }

    @Override
    public ActivityCategoryVo toData(ActivityCategory data, String[] fields) {
        return data.copy(new ActivityCategoryVo());
    }
}
